<?php
require_once(AcanROOT.'class/lib/phpmailer/class.phpmailer.php');
function amail($tomail,$toname,$title,$body,$fujian=1){

	$amail_add = 'mail@abans.cn';
	$amail_reply = 'mail@abans.cn';
	$amail_name = 'mail@abans.cn';
	$amail_user = 'mail@abans.cn';
	$amail_pw = '100200';

	$mail = new PHPMailer(true);
	$mail->IsSMTP();

	try{
		$mail->Host			="smtp.exmail.qq.com";		// SMTP server
		$mail->SMTPDebug	=1;					// 使用SMTP调试信息(用于测试)
		$mail->SMTPAuth		=true;				// 使用SMTP认证
		$mail->Host			="smtp.exmail.qq.com";		// 设置SMTP server
		$mail->Port			=25;				// 设置SMTP port
		$mail->Username		=$amail_user;		//邮箱SMTP用户名
		$mail->Password		=$amail_pw;			//邮箱SMTP密码
		$mail->AddReplyTo($amail_reply,$amail_name);	//回复地址,姓名
		$mail->AddAddress($tomail,$toname);		//收件人
		$mail->SetFrom($amail_add,$amail_name);	//发件人
		$mail->AddReplyTo($amail_add,$amail_name);
		$mail->Subject = $title;				//标题
		$mail->AltBody = '要查看邮件，请使用HTML兼容的电子邮件阅读器!';	// 可选- MsgHTML将自动创建一个备用
		$mail->MsgHTML($body);					//内容
		if($fujian!==1){
			$mail->AddAttachment($fujian);		// 附件
		}
		$mail->Send();
		$amail_msg['msg']="成功发送至$tomail 登入你的邮箱即可查看</p>\n";
		$amail_msg['rs']="1";
	}catch(phpmailerException $e){
		$amail_msg['error']=$e->errorMessage();	//PHPMailer的错误信息
		$amail_msg['msg']="发送至$tomail 失败请重试</p>\n";
		$amail_msg['rs']="0";
	}catch(Exception $e) {
		$amail_msg['error']=$e->getMessage();	//错误信息
		$amail_msg['msg']="发送至$tomail 失败请重试</p>\n";
		$amail_msg['rs']="0";
	}
	return $amail_msg;
}

?>